// ==UserScript==
// @name Abe Parature Fixes for Chrome
// @description   scripts for chrome
// @include     https://*.parature.com/*
// @include     https://*.parature.net/*
// @match       https://*.parature.com/*
// @match		https://*.parature.net/*
// ==/UserScript==

/*********************************************
* Add actions to the top, put in a single line, not wrapped
**********************************************/
if (document.location.href.search(/ticketdetail/i) != -1)
{
	//clone the actions
	var actions = document.getElementById("action_row");
	var actions2 = actions.cloneNode(true);
	//Put the actions in the header
	var tdTags = document.getElementsByTagName("td");
	for (var i = 0; i < tdTags.length ; i++)
		{
		var oneTD = tdTags[i];
		if (oneTD.className == "winTabContent")
			{
			oneTD.innerHTML = actions2.innerHTML;
			oneTD.innerHTML = oneTD.innerHTML.replace(/<br>/ig,'').replace(/class="formButton"/ig,'style="cursor:pointer; cursor:hand;"');
			}
		}
}

/*********************************************
* Add Edit Icon to Ticket List page links
**********************************************/
if (document.location.href.search(/ticketlist/i) != -1)
{
 	var anchorTags = document.getElementsByTagName('a');
	for (var i = 0; i < anchorTags.length ; i++)
		{
		var viewLink = anchorTags[i];
		var editLink = viewLink.cloneNode(true);
			if ((viewLink.href.search(/Detail/g) != -1) && (viewLink.nextSibling == null))
			{
			editLink.href = viewLink.href.replace(/Detail/g,'Edit');
			editLink.innerHTML = '<img src="https://d1.parature.com/ics/inc/css/parature/images/icons/iArticleEdit.png" width="14" height="14"/>';
			editLink.class = '';
			viewLink.parentNode.appendChild(editLink);
			}
		}
}

/*********************************************
* Change default width of left frame
**********************************************/
if (document.location.href.search(/parature.com/i) != -1)
{
	var contentCols = document.getElementById("contentCols");
	contentCols.cols = '285, *';
}

/*********************************************
* Hide System rows from Ticket History - work in progress

if (document.location.href.search(/ticketDetail/i) != -1)
{		
	window.opera.addEventListener('AfterEvent.load',
	function ()
		{
		var trTags = document.getElementsByTagName("tr");
		for (var i = 0; i < trTags.length; i++)
			{
			var oneTR = trTags[i];
			//var abe = oneTR.childNodes[2].text
			actionPerformer = oneTR.childNodes[2];
			alert(actionPerformer.nodeType);
			---
			if (oneTR.childNodes[2].nodeValue.search(/System/i) != -1)
				{
				alert("hi");
				}
			-----	
			}
		}, false);
}
**********************************************/